package com.wyy.controller;

import com.wyy.beans.User;
import com.wyy.common.Result;
import com.wyy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping
public class AccountController {

    @Autowired
    private UserService userService;

    @GetMapping("/doLogin")
    public Result<User> login(User user) {
        return userService.login(user);
    }

    @GetMapping("/login")
    public String unLogin() {
        return "Please login ...";
    }

    @PostMapping("/register")
    public Result<User> register(@RequestBody User user) {
        return userService.addUser(user);
    }

    @GetMapping("/loginOut")
    public Result<String> loginOut() {
        return userService.loginOut();
    }
}
